package com.cloud.pole.rabbit;

import java.io.InputStream;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.util.Arrays;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.cloud.pole.common.constant.CommonConstants;
import com.cloud.pole.common.exception.BaseException;
import com.cloud.pole.common.exception.ParamException;
import com.cloud.pole.common.msg.ApiRestResponse;
import com.cloud.pole.common.util.RegexUtils;
import com.cloud.pole.weixin.biz.WxAppBiz;
import com.cloud.pole.weixin.model.entity.WxApp;
import com.cloud.pole.weixin.model.entity.WxUser;
import com.cloud.pole.weixin.service.MinProgramService;
import com.cloud.pole.weixin.service.WechatApiService;
import com.cloud.pole.weixin.util.wechat.SHA1;
import com.cloud.pole.weixin.util.wechat.WxCommonConstants;
import com.cloud.pole.weixin.wechat.domain.BaseRespMsg;
import com.cloud.pole.weixin.wechat.handler.DefaultSession;
import com.cloud.pole.weixin.wechat.handler.HandleMessageAdapter;
import com.cloud.pole.weixin.wechat.message.Msg;
import com.cloud.pole.weixin.wechat.message.Msg4Event;
import com.cloud.pole.weixin.wechat.message.Msg4Text;
import lombok.extern.slf4j.Slf4j;

@Controller
@RequestMapping("rabbit/front")
@Slf4j
public class RabbitController {

    @Autowired
    private Sender sender;

	@ResponseBody
    @RequestMapping(value = "/test")
    public ApiRestResponse<String> test(){   	
    	try {
    		for(int i = 0 ; i < 100; i ++) {
        		sender.send();
        		sender.send01();
    		}
    		return ApiRestResponse.success(CommonConstants.STATUS_OK_MESSAGE, null);
    	} catch (BaseException e) {
			return ApiRestResponse.fail(e.getStatus(), e.getMessage(), null);
		} catch (Exception e) {
			log.error(CommonConstants.STATUS_ERROR_MESSAGE + "{}", e.getMessage(), e);
			return ApiRestResponse.fail(CommonConstants.STATUS_ERROR_MESSAGE, null);
		}
    }
}
